#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int d[N],v[N],a[N],l[N],r[N],p[N],cs[N];
pair<int,int> jc[N];
bool flag[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int T;
    cin>>T;
    while(T--){
        memset(l,-1,sizeof l);
        memset(r,-1,sizeof r);
        int n,m,L,V,ct=0,sum=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;++i){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]>0){
                if(v[i]>V) l[i]=d[i],r[i]=L;
                else{
                        double x=1.0*(V*V-v[i]*v[i])/2/a[i];
                        l[i]=int(floor(1.0*x+1+d[i])),r[i]=L;
                }
            }
            if(a[i]==0){
                if(v[i]>V) l[i]=d[i],r[i]=L;
            }
            if(a[i]<0){
                if(v[i]>V){
                        double x=1.0*(v[i]*v[i]-V*V)/2/(-a[i]);
                        r[i]=int(floor(1.0*x-0.0000001+d[i])),l[i]=d[i];
                }
            }
        }
        for(int i=1;i<=m;++i){
            cin>>p[i];
            jc[i].second=i;
            for(int j=1;j<=n;++j){
                if(l[j]<=p[i]&&p[i]<=r[j]) cs[j]++,jc[i].first++;
            }
        }
        for(int i=1;i<=n;++i){
            if(cs[i]) ++ct;
            else l[i]=r[i]=-1;
        }
        cout<<ct<<" ";
        sort(jc+1,jc+m+1);
        for(int i=1;i<=m;++i){
                //cout<<jc[i].second<<" ";
            bool f=1;
            for(int j=1;j<=n;++j){
                if(l[j]<=p[jc[i].second]&&p[jc[i].second]<=r[j]){
                    --cs[j],flag[j]=1;
                }
            }
            for(int j=1;j<=n;++j){
                if(cs[j]==0&&l[j]!=-1)f=0;
            }
            if(f) ++sum;
            else for(int j=1;j<=n;++j) if(l[j]!=-1&&flag[j])++cs[j];
            //cout<<endl;
            //for(int j=1;j<=n;++j) cout<<cs[j]<<" ";
            //cout<<endl;
            memset(flag,0,sizeof flag);
        }
        cout<<sum<<endl;
        memset(cs,0,sizeof cs);
        memset(jc,0,sizeof jc);
        memset(p,0,sizeof p);
    }
}
